/** 
    @file frame_listener.hpp
    @brief Frame Listener Class
*/

#ifndef PM3_FRAME_LISTENER_HPP
#define PM3_FRAME_LISTENER_HPP

#include "input/input_manager.hpp"
#include "pixel/pixelworld.hpp"
#include "hud/text_overlay.hpp"
#include "physics.hpp"

#include <Ogre.h>

namespace pm3 {

    /**
        @class FRAME_LISTENER
        @brief The Frame Listener Class
    */
    class FRAME_LISTENER: public OIS::KeyListener, public OIS::MouseListener, public Ogre::FrameListener {
    friend class GAME;
	public:
        /**
            @brief Constructor
        */
        FRAME_LISTENER();
        /**
            @brief Destructor
        */
        ~FRAME_LISTENER();

        /**
            @brief Override function for the KeyPressed event
            @param[in] r_event Reference to OIS KeyEvent
            @return True if the key can be removed from the buffer and false otherwise
        */
        virtual bool keyPressed( const OIS::KeyEvent &r_event );
        /**
            @brief Override function for the KeyReleased event
            @param[in] r_event Reference to OIS KeyEvent
            @return True if the key can be removed from the buffer and false otherwise
        */
        virtual bool keyReleased( const OIS::KeyEvent &r_event );

        /**
            @brief Override function for the MouseMove event
            @param[in] r_event Reference to OIS MouseEvent
            @return True if the event can be removed from the buffer and false otherwise
        */
        virtual bool mouseMoved( const OIS::MouseEvent &r_event );
        /**
            @brief Override function for the MousePressed event
            @param[in] r_event Reference to OIS MouseEvent
            @param[in] i_button Button index that was pressed down
            @return True if the event can be removed from the buffer and false otherwise
        */
        virtual bool mousePressed( const OIS::MouseEvent &r_event, OIS::MouseButtonID i_button );
        /**
            @brief Override function for the MouseRelase event
            @param[in] r_event Reference to OIS MouseEvent
            @param[in] i_button Button index that was pressed down
            @return True if the event can be removed from the buffer and false otherwise
        */
        virtual bool mouseReleased( const OIS::MouseEvent &r_event, OIS::MouseButtonID i_button );

        /**
            @brief Override function for the FrameStarted event
            @param[in] r_event Reference to Ogre FrameEvent
            @return False if the application should be closed and True, when the application should keep on running
        */
        virtual bool frameStarted( const Ogre::FrameEvent &r_event );

        /**
            @brief Override function for the FrameEnded event
            @param[in] f_event Reference to Ogre FrameEvent
            @return False if the application should be closed and True, when the application should keep on running
        */
        virtual bool frameEnded( const Ogre::FrameEvent &f_event );

    protected:
        /**
            @brief Initializes the listener
        */
        void init();

        //! Pointer to the input manager to receive keyboard and mouse events from
        INPUT_MANAGER *m_input_manager;

        //! Number of screenshots taken
        int m_num_screenshots;

	private:
        //! A timer counter
        Ogre::Real m_time;

        //! Is Esc pressed? Needed for closing the application
        bool m_esc_pressed;
    };

}

#endif

